<div class="uimssVarieties" style="height: 100%;width:100%;overflow:auto;position: relative;padding-top: 42px;background-color: #fff;">
    <div class="button-group-head" style="position: absolute;left: 0;top: 0;width: 100%;border-bottom: none;">



        <span class="hrp-btn hrp-btn-add" id="batchUpdatePrice" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>批量更新单价</span>
        <!--<span class="hrp-btn hrp-btn-add" id="excelExport" style="float: right;"><i class="fa fa-file-excel-o" style="padding-right: 4px;"></i>导出excel</span>-->
        <span class="hrp-btn hrp-btn-add" id="editOpenDialog" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>修改单价规则</span>
        <span class="hrp-btn hrp-btn-add" id="openDialog" style="float: right;"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加单价规则</span>
        <!--<span  class="hrp-btn hrp-btn-refresh"><i class="fa fa-refresh" style="padding-right: 4px;"></i>刷新</span>-->

        <input type="hidden" id="idkey" value="-1"/>
        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">开始日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeKsrq" name="dept">
        </span>
        <span style="height:40px;line-height: 34px;float: left;padding-right: 5px;font-size:14px;">结束日期:</span>
        <span style="height: 40px;float: left;padding-right: 20px;">
            <input id="sendTimeJsrq" name="dept">
        </span>




    </div>
    <!--<div class="jxkhzbk-toolbar" style="position: absolute;left: 0;top: 42px;width: 100%;">-->
    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="receiverId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">收货方:</span>-->

    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="supplierId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">发货方:</span>-->




    <!--<span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">-->
    <!--<input id="varietiesId" name="dept">-->
    <!--</span>-->
    <!--<span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">种类:</span>-->
    <!--</div>-->
    <div style="height: 100%;width: 100%;border:1px solid #cccccc;position: relative;">
        <div class="uimssVarieties-content-left" style="position: absolute;left: 0;top:0;height: 100%;width: 450px;">
            <div style="position: absolute;left: 0;top:0;width:150px;height:100%;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input"  data-action="varietiesIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索分类"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="varietiesIdTree"></ul>
                </div>
            </div>
            <div style="position: absolute;left: 150px;top:0;width:150px;height:100%;;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input"   data-action="supplierIddSearch"  style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索发货地"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="supplierIdTree"></ul>
                </div>
            </div>
            <div style="position: absolute;right: 0;top:0;width:150px;height:100%;border-left:1px solid #ccc;overflow: auto;padding-top: 30px;">
                <div style="position: absolute;left: 0;top:0;width: 100%;height: 30px;">
                    <input class="search-input" data-action="receiverIdSearch"   style="height: 30px;border-bottom:1px solid #ccc;width:100%;margin: 0;padding: 0;padding: 2px;line-height: 30px;" placeholder="搜索收货地"/>
                </div>
                <div style="height: 100%;width: 100%;overflow: auto;">
                    <ul id="receiverIdTree"></ul>
                </div>
            </div>
        </div>
        <div class="uimssVarieties-content-main" style="height: 100%;margin-left: 450px;border-left:1px solid #ccc;overflow: auto;">
            <table id="dg" class="easyui-datagrid" style="width:100%;">
                <!--<thead>-->
                <!--<tr>-->
                <!--<th  width="15%">Item ID(15%)</th>-->
                <!--<th  width="15%">Product(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th  width="15%">List Price(15%)</th>-->
                <!--<th width="15%">List Price(15%)</th>-->
                <!--</tr>-->
                <!--</thead>-->
            </table>
        </div>
    </div>




    <div id="editActionDialog"  class="ss-dialog" style="width:600px;height: 500px;margin-top: -300px;margin-top: -230px;">
        <span class="ss-dialog-close" style="">X</span>
        <div class="ss-dialog-head" style="font-weight: 600;" id="varietiesIdText">

        </div>
        <div class="ss-dialog-content">
            <!--<div class="row" style="height: 60px;">-->
                <!--<input type="hidden" id="idkey" value="-1"/>-->
                <!--<span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">开始日期:</span>-->
                <!--<span style="width:35%;float:left;padding-top: 10px;"><input  id="sendTimeKsrq" type="text"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>-->
                <!--<span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">结束日期</span>-->
                <!--<span style="width:35%;float:left;padding-top: 10px;"><input id="sendTimeJsrq" type="text" value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>-->
            <!--</div>-->

            <div style="height:250px;width:100%;overflow: auto;border:1px solid #ccc;padding: 4px;">
                <!--<div class="varietiesIdText">-->
                    <!--<span style="display: block;height: 20px;line-height: 20px;text-align: center;font-size: 18px;font-weight: 600;">分类:</span>-->
                    <!--<span  style="display: block;line-height: 20px;text-align: left;font-size: 12px;padding: 4px;">-->
                        <!--全部分类,天之路,临泉水利,文阳,开信,三棵树,三棵树水稳站,敬烨防护用品公司,电动车厂,潘村农场,平原,凤阳东路,-->
                        <!--三界部队,石坝农田改造,华亿,瑞丰水利,洪庙道班,华宇建设（戴）,丰山集涵管厂,五河,杨传英,涧溪磅房,官山料场,炭元科技,-->
                        <!--龙盛,明达,江河水利,伟成,四川宏大,达锋涵管厂,淮北信和,三棵树拌合站,三棵树商硂,博信达,中寅,鸿佑,明南,江苏顺德,园区苏巷,-->
                        <!--韩雨成公司,孙小虹,黄山华宇（戴）,宏大,环湖大道明达,江河,红河水利,大辛庄（明南）,环湖大道,达锋,-->
                        <!--鲁峰村,安徽路网,蒲塘村,路达,仇集,公路局,临泉潘村,楚辰,惠农,长隆,智泽,砼石,滨河B区,滨河安置小区-->
                    <!--</span>-->
                <!--</div>-->
                <div class="supplierIdText" style="position: relative;border:1px solid #ccc;">
                    <span style="display: block;height: 20px;line-height: 20px;text-align: center;font-size: 18px;font-weight: 600;">发货地:</span>
                    <span  id="supplierIdText-content" style="display: block;line-height: 22px;text-align: left;font-size: 14px;padding: 4px;">

                    </span>
                    <i class="fa fa-long-arrow-down" style="position: absolute;left:50%;bottom:-30px;font-size:20px;line-height:20px;color:#000;width:20px;height:20px;margin-left-10px;text-align: center"></i>
                </div>
                <div class="receiverIdText" style="margin-top: 40px;border:1px solid #ccc;">
                    <span style="display: block;height: 20px;line-height: 20px;text-align: center;font-size: 18px;font-weight: 600;">收货地:</span>
                    <span id="receiverIdText-content"  style="display: block;line-height: 22px;text-align: left;font-size: 14px;padding: 4px;">

                    </span>
                </div>
            </div>

            <div class="row" style="height: 60px;">
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">单价:</span>
                <span style="width:35%;float:left;"><input  id="price" type="text" placeholder="单价" value="0"  style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:15%;height:60px;line-height:60px;float:left;text-align: center;">备注:</span>
                <span style="width:35%;float:left;"><input  id="memo" type="text" placeholder="备注" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>

            </div>
        </div>
        <div  class="ss-dialog-head" style="">
            <span class="hrp-btn hrp-btn-delete" style="float: right;" id="btn-cancel"><i class="fa fa-close" style="padding-right: 4px;"></i>取消</span>
            <span class="hrp-btn hrp-btn-add" style="float: right;" id="btn-save"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>
        </div>
    </div>
    <div id="mask-model" class="mask-model" style=""></div>

</div>


<script type="text/javascript">

    var dHeight = $(".uimssVarieties").height();

    var UserIndexPage={
        tableName:"UIMSS_SUPPLIERINFO",
        init:function () {


            this.initEvnets();
            this.initSendTimeKsrqCombox();
            this.initSendTimeJsrqCombox();

            this.initReceiverTree();
            this.initVarietiesTree();
            this.initSupplierTree();

            //this.initDateCombox();

            this.initGrid();

        },
        initVarietiesTree:function (searchValue) {
            $('#varietiesIdTree').tree({
                url:'common/getUimssVarietiesTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initSupplierTree:function (searchValue) {
            $('#supplierIdTree').tree({
                url:'common/getUimssSupplierTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initReceiverTree:function (searchValue) {
            $('#receiverIdTree').tree({
                url:'common/getUimssReceiverTree',
                checkbox:true,
                queryParams:{
                    "searchValue":searchValue
                }
            });
        },
        initSendTimeJsrqCombox:function () {

            var that= this;
            $('#sendTimeKsrq').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeKsrq').datebox('setValue', that.formatterDate(that.setDateMonth(new Date())));
        },
        initSendTimeKsrqCombox:function () {

            var that= this;
            $('#sendTimeJsrq').datebox({
                formatter : function(date){
                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });
            $('#sendTimeJsrq').datebox('setValue', that.formatterDate(new Date()));
        },
        initEvnets:function () {
            var that = this;
            $(window).resize(function () {
                $('#dg').datagrid("resize")
            })

            //添加保存
            $("#openDialog").on("click",function () {
                var varietiesIdArr = $('#varietiesIdTree').tree('getRoots')[0].children;
                console.log(varietiesIdArr);
                var varietiesIdArrInt=0;
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(varietiesIdArr[i].checked==true){
                        varietiesIdArrInt++;
                    }
                }
                if(varietiesIdArrInt>1){
                    $.messager.show({title: '提示', msg: '分类选择过多请选择一个分类', timeout: 1000, showType: 'slide'});
                    return;
                }

                var varietiesIdArrTwo = $('#varietiesIdTree').tree('getChecked');
                if(varietiesIdArrTwo.length<1){
                    $.messager.show({title: '提示', msg: '请选择一个分类', timeout: 1000, showType: 'slide'});
                    return;
                }

                $("#varietiesIdText").text(varietiesIdArrTwo[0].text);

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdText='';
                for(var i=0;i<supplierIdArr.length;i++){

                    if(supplierIdArr[i].id!=-1){
                        if(i<supplierIdArr.length-1){
                            supplierIdText+=supplierIdArr[i].text+' - ';
                        }else{
                            supplierIdText+=supplierIdArr[i].text;
                        }
                    }
                }
                $("#supplierIdText-content").text(supplierIdText)

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdText='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(receiverIdArr[i].id!=-1){
                        if(i<receiverIdArr.length-1){
                            receiverIdText+=receiverIdArr[i].text+' - ';
                        }else{
                            receiverIdText+=receiverIdArr[i].text;
                        }
                    }
                }
                $("#receiverIdText-content").text(receiverIdText);

                $("#idkey").val("-1");
                $('#editActionDialog').slideDown(300);
                $("#mask-model").slideDown(300);
            })



            //修改保存
            $("#editOpenDialog").on("click",function () {
                var varietiesIdArr = $('#varietiesIdTree').tree('getRoots')[0].children;
                console.log(varietiesIdArr);
                var varietiesIdArrInt=0;
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(varietiesIdArr[i].checked==true){
                        varietiesIdArrInt++;
                    }
                }
                if(varietiesIdArrInt>1){
                    $.messager.show({title: '提示', msg: '分类选择过多请选择一个分类', timeout: 1000, showType: 'slide'});
                    return;
                }

                var varietiesIdArrTwo = $('#varietiesIdTree').tree('getChecked');
                if(varietiesIdArrTwo.length<1){
                    $.messager.show({title: '提示', msg: '请选择一个分类', timeout: 1000, showType: 'slide'});
                    return;
                }

                $("#varietiesIdText").text(varietiesIdArrTwo[0].text);

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdText='';
                for(var i=0;i<supplierIdArr.length;i++){

                    if(supplierIdArr[i].id!=-1){
                        if(i<supplierIdArr.length-1){
                            supplierIdText+=supplierIdArr[i].text+' - ';
                        }else{
                            supplierIdText+=supplierIdArr[i].text;
                        }
                    }
                }
                $("#supplierIdText-content").text(supplierIdText)

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdText='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(receiverIdArr[i].id!=-1){
                        if(i<receiverIdArr.length-1){
                            receiverIdText+=receiverIdArr[i].text+' - ';
                        }else{
                            receiverIdText+=receiverIdArr[i].text;
                        }
                    }
                }
                $("#receiverIdText-content").text(receiverIdText);

                $('#editActionDialog').slideDown(300);
                $("#mask-model").slideDown(300);
            })

            $("#batchUpdatePrice").on("click",function () {
                $.messager.confirm('提醒',"是否确认批量更新单价",function(r){
                    if (r){
                        alert('ok');
                    }
                });
            })

            $(".uimssVarieties").on("click",".btn-singleUpdatePrice",function () {

                var id = $(this).attr("data-id");
                $.messager.confirm('提醒',"是否确认更新单价",function(r){
                    if (r){
                        $.post("priceSetting/batchUpdatePrice", {
                            "id":id
                        }, function (result) {
                            if (result.status == 200) {
                                $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                            } else {
                                $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                            }
                        })
                    }
                });
            })

            $("#btn-price-cancel").on("click",function () {
                $("#mask-model").hide(50);
                $('#updatePriceActionDialog').hide(50);
            })
            $("#btn-price-save").on("click",function () {
                var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');


                var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                var varietiesIdStr='';
                //console.log(varietiesIdArr);
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(i<varietiesIdArr.length-1){
                        varietiesIdStr+=varietiesIdArr[i].id+',';
                    }else{
                        varietiesIdStr+=varietiesIdArr[i].id;
                    }
                }

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdStr='';
                for(var i=0;i<supplierIdArr.length;i++){
                    if(i<supplierIdArr.length-1){
                        supplierIdStr+=supplierIdArr[i].id+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                    }
                }
                //console.log(supplierIdStr);

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }
                //console.log(receiverIdStr);

                var price = $("#update-price").val();
                $.post("transprotRecord/updateTransportRecordDataPrice", {
                    "sendTimeKsrq":sendTimeKsrq,
                    "sendTimeJsrq":sendTimeJsrq,
                    "varietiesIdStr":varietiesIdStr,
                    "supplierIdStr":supplierIdStr,
                    "receiverIdStr":receiverIdStr,
                    "price":price
                }, function (result) {
                    if (result.status == 200) {
                        $("#mask-model").hide(50);
                        $('#updatePriceActionDialog').hide(50);
                        $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                    } else {
                        $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                    }
                })

            })


            $(".ss-dialog-close").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
                $('#updatePriceActionDialog').hide();
            })

            $("#excelExport").on("click",function () {
                var sendTimeKsrq = $('#sendTimeKsrq').datebox('getValue');
                var sendTimeJsrq = $('#sendTimeJsrq').datebox('getValue');

                var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
                var varietiesIdStr='';
                for(var i=0;i<varietiesIdArr.length;i++){
                    if(i<varietiesIdArr.length-1){
                        varietiesIdStr+=varietiesIdArr[i].id+',';
                    }else{
                        varietiesIdStr+=varietiesIdArr[i].id;
                    }
                }

                var supplierIdArr = $('#supplierIdTree').tree('getChecked');
                var supplierIdStr='';
                for(var i=0;i<supplierIdArr.length;i++){
                    if(i<supplierIdArr.length-1){
                        supplierIdStr+=supplierIdArr[i].id+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                    }
                }

                var receiverIdArr = $('#receiverIdTree').tree('getChecked');
                var receiverIdStr='';
                for(var i=0;i<receiverIdArr.length;i++){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                    }
                }
                window.location.href="export/export1?sendTimeKsrq="+sendTimeKsrq+"&sendTimeJsrq="+sendTimeJsrq+"&varietiesIdStr="+varietiesIdStr+"&supplierIdStr="+supplierIdStr+"&receiverIdStr="+receiverIdStr+"&page=1&rows=60";
            })

            $(".uimssVarieties").on("keyup",".search-input",function () {
                var newValue = $(this).val();
                var oldValue=$(this).data("oldValue");
                if(!oldValue){
                    oldValue="";
                }
                if( $(this).attr("data-action")=="varietiesIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        that.initVarietiesTree(newValue);
                    }
                }else if($(this).attr("data-action")=="supplierIddSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        that.initSupplierTree(newValue);
                    }
                }else if( $(this).attr("data-action")=="receiverIdSearch"){
                    if($.trim(newValue)!=$.trim(oldValue)){
                        that.initReceiverTree(newValue);
                    }
                }

                $(this).data("oldValue",newValue);
            })

            $("#btn-save").on("click",function () {
                that.saveData();
            })

            $("#btn-cancel").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
            })

            //修改
            $(".uimssVarieties").on("click",".btn-edit",function () {
                var id = $(this).attr("data-id");
                //console.log(id);
                $("#idkey").val(id);

                var startTime = $.trim($(this).attr("data-startTime"));
                var endTime = $.trim($(this).attr("data-endTime"));

                var varietiesId = $.trim($(this).attr("data-varietiesId"));
                var varietiesIdTreeArr = $('#varietiesIdTree').tree('getRoot').children;
                for(var i=0;i<varietiesIdTreeArr.length;i++){
                    $('#varietiesIdTree').tree('uncheck',varietiesIdTreeArr[i].target);
                }
                var varietiesIdTreenode = $('#varietiesIdTree').tree('find',varietiesId);
                $('#varietiesIdTree').tree('check',varietiesIdTreenode.target);

                var supplierIdTreeArr = $('#supplierIdTree').tree('getRoot').children;
                for(var i=0;i<supplierIdTreeArr.length;i++){
                    $('#supplierIdTree').tree('uncheck',supplierIdTreeArr[i].target);
                }
                var supplierIdStr = $.trim($(this).attr("data-supplierIdStr"));
                var supplierIdStrArr = supplierIdStr.split(",");
                for(var i=0;i<supplierIdStrArr.length;i++){
                    var supplierIdTreenode = $('#supplierIdTree').tree('find',supplierIdStrArr[i]);
                    $('#supplierIdTree').tree('check',supplierIdTreenode.target);
                }

                var receiverIdTreeArr = $('#receiverIdTree').tree('getRoot').children;
                for(var i=0;i<receiverIdTreeArr.length;i++){
                    $('#receiverIdTree').tree('uncheck',receiverIdTreeArr[i].target);
                }
                var receiverIdStr = $.trim($(this).attr("data-receiverIdStr"));
                var receiverIdStrArr=receiverIdStr.split(",");
                for(var i=0;i<receiverIdStrArr.length;i++){
                    var receiverIdTreenode = $('#receiverIdTree').tree('find',receiverIdStrArr[i]);
                    $('#receiverIdTree').tree('check',receiverIdTreenode.target);
                }

                var memo = $.trim($(this).attr("data-memo"));
                var price = $.trim($(this).attr("data-price"));

                $('#sendTimeKsrq').datebox('setValue', startTime);
                $('#sendTimeJsrq').datebox('setValue', endTime);

                $("#memo").val(memo);
                $("#price").val(price);

                //$('#editActionDialog').slideDown(300);
                //$("#mask-model").slideDown(300);
            })
        },
        saveData:function () {
            var that = this;

            var startTime = $('#sendTimeKsrq').datebox('getValue');
            var endTime = $('#sendTimeJsrq').datebox('getValue');

            var varietiesIdArr = $('#varietiesIdTree').tree('getChecked');
//            var varietiesIdStr='';
//            for(var i=0;i<varietiesIdArr.length;i++){
//                if(i<varietiesIdArr.length-1){
//                    varietiesIdStr+=varietiesIdArr[i].id+',';
//                }else{
//                    varietiesIdStr+=varietiesIdArr[i].id;
//                }
//            }

            var varietiesId = varietiesIdArr[0].id;
            var varietiesName = varietiesIdArr[0].text;
            console.log(varietiesName);


            var supplierIdArr = $('#supplierIdTree').tree('getChecked');
            var supplierIdStr='';
            var supplierStrName='';
            for(var i=0;i<supplierIdArr.length;i++){
                if(supplierIdArr[i].id!=-1){
                    if(i<supplierIdArr.length-1){
                        console.log(supplierIdArr[i])
                        supplierIdStr+=supplierIdArr[i].id+',';
                        supplierStrName+=supplierIdArr[i].text+',';
                    }else{
                        supplierIdStr+=supplierIdArr[i].id;
                        supplierStrName+=supplierIdArr[i].text;
                    }
                }
            }

            var receiverIdArr = $('#receiverIdTree').tree('getChecked');
            var receiverIdStr='';
            var receiverStrName='';
            for(var i=0;i<receiverIdArr.length;i++){
                if(receiverIdArr[i].id!=-1){
                    if(i<receiverIdArr.length-1){
                        receiverIdStr+=receiverIdArr[i].id+',';
                        receiverStrName+=receiverIdArr[i].text+',';
                    }else{
                        receiverIdStr+=receiverIdArr[i].id;
                        receiverStrName+=receiverIdArr[i].text;
                    }
                }
            }

            var price=$.trim($("#price").val());
            if(!that.checkNumber(price)){
                $.messager.show({title: '提示', msg: '请输入合法的单价', timeout: 1000, showType: 'slide'});
                return;
            }
            var memo = $.trim($("#memo").val());


            $.post("priceSetting/savePriceSetting", {
                "id":$("#idkey").val(),
                "startTime":startTime,
                "endTime":endTime,
                "varietiesId":varietiesId,
                "varietiesName":varietiesName,
                "supplierIdStr":supplierIdStr,
                "supplierStrName":supplierStrName,
                "receiverIdStr":receiverIdStr,
                "receiverStrName":receiverStrName,
                "price":price,
                "memo":memo
            }, function (result) {
                if (result.status == 200) {

                    that.initGrid();
                    $('#editActionDialog').slideUp(300);
                    $("#mask-model").slideUp(300);
                    $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                } else {
                    $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                }
            })
        },
        //得到当前日期
        formatterDate : function(date,type) {
            var day = date.getDate() > 9 ? date.getDate() : "0" + date.getDate();
            var month = (date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1);
            return date.getFullYear() + '-' + month + '-' + day;

        },
        //验证字符串是否是数字
        checkNumber:function(theObj) {
            var reg = /^[0-9]+.?[0-9]*$/;
            if (reg.test(theObj)) {
                return true;
            }
            return false;
        },
        initGrid:function () {
            $('#dg').datagrid({
                url: "priceSetting/getPriceSettingByPage",
                queryParams: {

                },
                pagination: true,
                singleSelect: true,
                height:dHeight-3,   //表格高度，可指定高度，可自动
                pageNumber: 1,
                pageSize: 60,
                pageList: [30, 60,90],
                fitColumns:true,
                remoteSort:true,
                loadMsg: "正在加载数据",
                nowrap: false,
                striped: true,  //奇偶行是否使用不同的颜色
                columns:[
                    [
                        //{field:'id',title:'编号',width:"5%"},
                        {field:'id',title:'序号',width:"5%",sortable:true},
                        {field:'startTime',title:'开始日期',width:"15%",sortable:true},
                        {field:'endTime',title:'截止日期',width:"15%",sortable:true},
                        {field:'varietiesName',title:'种类',width:"10%",sortable:true},
                        //{field:'supplierStrName',title:'发货方',width:"12%",sortable:true},
                        {
                            field: 'supplierStrName', title: '发货方', width: "15%",
                            formatter: function (value, row, index) {
                                return "<span style='display: block;height:40px;line-height: 40px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;' title='"+value+"'>"+value+"</span>";
                            }
                        },
                        //{field:'receiverStrName',title:'收货方',width:"12%",sortable:true},
                        {
                            field: 'receiverStrName', title: '收货方', width: "15%",
                            formatter: function (value, row, index) {
                                return "<span style='display: block;height:40px;line-height: 40px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;' title='"+value+"'>"+value+"</span>";
                            }
                        },
                        //{field:'cph',title:'车牌号',width:"10%"},
//                        {field:'cmz',title:'车毛重',width:"5%"},
                        //{field:'csz',title:'车身重',width:"5%"},
                        {field:'price',title:'单价',width:"10%",sortable:true},
                        //{field:'times',title:'次数',width:"5%"},
                        {field:'memo',title:'备注',width:"10%"},
                        {
                            field: 'edit', title: '操作', width: "10%",
                            formatter: function (value, row, index) {
                                return "<a class='btn-edit' href='#' data-id='"+row.id+"'  data-startTime='"+row.startTime+"' data-endTime='"+row.endTime+"' data-varietiesId='"+row.varietiesId+"' data-supplierIdStr='"+row.supplierIdStr+"' data-receiverIdStr='"+row.receiverIdStr+"' data-memo='"+row.memo+"' data-price='"+row.price+"'>修改</a>"
                            }
                        },
                        {
                            field: 'updatePrice', title: '更新单价', width: "10%",
                            formatter: function (value, row, index) {
                                return "<a class='btn-singleUpdatePrice'  data-id='"+row.id+"'  href='#' >更新</a>"
                            }
                        }
                    ]
                ]
            });

        },
        setDateMonth:function (date) {
            var d = new Date(date);
            var month = d.getMonth();
            if (11 === month) {
                var year = d.getFullYear();
                d.setMonth(0);
                d.setFullYear(year + 1);
            } else {
                d.setMonth(month - 1);
            }
            return d;
        },
        initVarietiesComBox:function (id) {
            $('#varietiesId').combobox({
                url:"common/getUimssVarietiesDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {
                    //$("#price").val(record.value);
                },
                onLoadSuccess:function () {

                }
            });
        },
        initSupplierComBox:function (id) {
            $('#supplierId').combobox({
                url:"common/getUimssSupplierDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initReceiverCombox:function (id) {
            $('#receiverId').combobox({
                url:"common/getUimssReceiverDropList",
                queryParams: {
                    "id": id
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:200,
                onSelect:function (record) {

                },
                onLoadSuccess:function () {

                }
            });
        },
        initDateCombox:function () {

            var that= this;
            $('#sendTime').datebox({
                formatter : function(date){

                    //var date = new Date();
                    var year = date.getFullYear();
                    var month = date.getMonth() + 1;
                    var day = date.getDate();
                    var hour = date.getHours();
                    month = month < 10 ? '0' + month : month;
                    day = day < 10 ? '0' + day : day;
                    hour = hour < 10 ? '0' + hour : hour;
                    return year + "-" + month + "-" + day ;
                },
                parser:function (s) {
                    s = s.replace(/\s+/,' ');//解决格式字符串中多个空格拼接在Firefox中无法兼容的问题
                    var t = Date.parse(s);
                    if (!isNaN(t)){
                        return new Date(t);
                    } else {
                        return new Date(s + ":00");
                    }
                },
                onSelect:function (date) {

                }
            });

            $('#sendTime').datebox('setValue', that.formatterDate(new Date()));
        }
    }
    $(function () {
        UserIndexPage.init();
    })
</script>